public class EmojiUtils {
    public static String filterEmoji(String source) {
        if (source == null || source.isEmpty()) return source;

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < source.length(); i++) {
            char codePoint = source.charAt(i);
            if (!isEmojiCharacter(codePoint)) {
                sb.append(codePoint);
            }
        }
        return sb.toString();
    }

    private static boolean isEmojiCharacter(char codePoint) {
        // 定义非表情字符的合法范围‌:ml-citation{ref="4,5" data="citationList"}
        return (codePoint == 0x0) ||
                (codePoint == 0x9) ||
                (codePoint == 0xA) ||
                (codePoint == 0xD) ||
                ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) ||
                ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) ||
                ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF));
    }
}
